import static org.hamcrest.CoreMatchers.instanceOf;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Scanner;

import org.junit.Test;

import com.situ.study.entity.User;

public class Client {

	public static void main(String[] args) {
		User user1 = new User();
		user1.setId(1);
		user1.setName("张三");
		user1.setAge(23);
		
		User user2 = new User(2, "lisi", 23, "男");
		
		int id = user1.getId();
		String name = user1.getName();
		System.out.println("id: " + id);
		System.out.println("name: " + name);
		// 生成了toString()方法之后，直接打印user对象，
		// 打印的就是toString返回的字符串
		System.out.println(user1);
		System.out.println(user2);
		
	}
	
	@Test
	public void test1() {
		// User[] users = new User[5];
		ArrayList<User> list = new ArrayList<>();
		// for (;;){}
		while (true) {
			// 主要实现控制台输入  Unreachable code
			Scanner scanner = new Scanner(System.in);
			System.out.println("请输入用户的id：");
			int id = scanner.nextInt();
			System.out.println("请输入用户名：");
			String name = scanner.next();
			System.out.println("请输入用户年龄");
			int age = scanner.nextInt();
			System.out.println("请输入性别：");
			String gender = scanner.next();
			User user = new User(id, name, age, gender);
			// System.out.println(user);
			list.add(user);
			
			System.out.println("您是否要退出 -1 退出 ");
			int quit = scanner.nextInt();
			if (quit == -1) {
				break;
			}
		}
		
		for (int i = 0; i < list.size(); i++) {
			User user = list.get(i);
			System.out.println(user);
		}
		
		for (User user : list) {
			System.out.println(user);
		}
	}
	
	@Test
	public void test2() {
		System.out.println("Client.test2()");
	}
	
	
	
	
}
